package com.ruoyi.client.controller;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.client.domain.SysMedical;
import com.ruoyi.client.service.ISysMedicalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 前端接口 Controller
 *
 * @author ruoyi
 * @date 2022-09-14
 */

@RestController
@RequestMapping("/api/client/medical")
public class ClientMedController extends BaseController {
    @Autowired
    private ISysMedicalService sysMedicalService;

    /**
     * 查询器械信息 列表
     */
    @GetMapping("/list1")
    public TableDataInfo list1(SysMedical sysMedical) {
        startPage();
        List<SysMedical> list = sysMedicalService.selectSysMedicalList(sysMedical);
        if (list.size() > 5) {//判断list长度
            list = list.subList(0, 4);//取前四条数据
        }
        return getDataTable(list);
    }

    /**
     * 查询器械信息 列表
     */
    @GetMapping("/list2")
    public TableDataInfo list2(SysMedical sysMedical) {
        startPage();
        List<SysMedical> list = sysMedicalService.selectSysMedicalList(sysMedical);
        if (list.size() >= 8) {//判断list长度
            list = list.subList(4, 8);//取前四条数据
        }
        return getDataTable(list);
    }

    /** 类别为的器械*/
    @GetMapping("/getList")
    public TableDataInfo getList(SysMedical sysMedical){
        startPage();
        List<SysMedical> list = sysMedicalService.selectSysMedicalList(sysMedical);
        return getDataTable(list);
    }

}
